﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Team4sCMDB
{
    public partial class Incident : Form
    {
        private Main main;
        private CI ci;

        public Incident(Main main, CI ci)
        {
            InitializeComponent();
            this.main = main;
            this.ci = ci;

            lbIncidents.DataSource = main.model.getTickets();
        }

        private void btnMeldIncident_Click(object sender, EventArgs e)
        {
            main.model.addTicket(ci, dtpDate.Value, cbTicketType.SelectedText, tbOnderwerp.Text, tbOmschrijving.Text);
            this.Close();
        }

        private void lbIncidents_DoubleClick(object sender, EventArgs e)
        {
            DialogResult result = MessageBox.Show("Wilt u dit incident afmelden?", "Afmelden?", MessageBoxButtons.YesNo);
            if (result == System.Windows.Forms.DialogResult.Yes)
            {
                if (main.isAdmin == true)
                {
                    main.model.addAfmeldDatum((IncidentClass)lbIncidents.SelectedItem, DateTime.Now);
                }
                else 
                {
                    MessageBox.Show("U kunt dit incident niet afmelden","U bent niet ingelogd als beheerder");
                }
            }
        }


    }
}
